#include "UsageEnvironment.hh"

#ifndef _AUDIO_INPUT_DEVICE_HH
#include "AudioInputDevice.hh"
#endif

typedef enum {
	WA_PCMU = 0,
	WA_PCM = 1,
	WA_PCMA = 6,
	WA_G726_16 = 8,
	WA_G726_24 = 9,
	WA_G726_32 = 10,
	WA_G726_40 = 11,	  
	WA_UNKNOWN
}WAV_AUDIO_FORMAT;

class IPCameraWAVAudioSource :
	public AudioInputDevice
{
public:
	static IPCameraWAVAudioSource* createNew(UsageEnvironment& env, char* url);
	Boolean isWAVAudioStreamFramer();

	unsigned numPCMBytes() const;
	void setScaleFactor(int scale);
	void seekToPCMByte(unsigned byteNumber);

	unsigned char getAudioFormat();

public:
	virtual u_int8_t type();

protected:
	IPCameraWAVAudioSource(UsageEnvironment& env, char* sdpLines);
	~IPCameraWAVAudioSource(void);

private:
	// redefined virtual functions:
	virtual void doGetNextFrame();
	virtual void doStopGettingFrames();
	virtual Boolean setInputPort(int portIndex);
	virtual double getAverageLevel() const;

private:
	double fPlayTimePerSample; // useconds
	unsigned fPreferredFrameSize;
	unsigned fLastPlayTime; // useconds
	unsigned fWAVHeaderSize;
	int fScaleFactor;

	unsigned char fAudioFormat;

public:
	int		int_stream_id;
	void*	ptr_frame_buffer;
};
